package com.shipwe.loans.ui.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.shipwe.adapter.ShipweRecyclerViewAdapter
import com.shipwe.adapter.ShipweViewHolderHelper
import com.shipwe.loans.R
import com.shipwe.loans.configs.ShipweConfigs
import com.shipwe.loans.utils.AppLoadImageUtil
import org.json.JSONObject

/**
 * Shipwe
 * @Author wwdeng
 * @CreateTime: 2024/11/25 11:51
 * @Annotation：贷款详情 - 账户列表
 */
class OrderDetailsWalletAdapter(recyclerView: RecyclerView?) : ShipweRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.fragment_step_auth_wallet_item) {
    override fun setItemChildListener(helper: ShipweViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
        helper.setItemChildClickListener(R.id.walletDelete)//删除
    }
    override fun fillData(helper: ShipweViewHolderHelper, position: Int, model: JSONObject) {
        var showName = model.optString("name","")
        if (showName.isEmpty() || showName == "null"){
            showName = "test"
        }
        helper.setText(R.id.walletTitle,showName)
        helper.setText(R.id.walletMobile,"+" + model.optString("account"))
        val walletLogo = helper.getImageView(R.id.walletLogo)
        AppLoadImageUtil.instance.loadImageUrl(mContext,walletLogo,model.optString("logo"), R.drawable.load_holder)

        //法语地区显示删除按钮
        if (ShipweConfigs.isFrench()){
            helper.setVisibility(R.id.walletDelete, View.VISIBLE)
        } else {
            helper.setVisibility(R.id.walletDelete, View.GONE)
        }
    }
}